<template>
    <el-dialog title="审核" :visible="visible" :show-close="false" width="1000px" center>
        <el-row>     
        <span style="margin-left: 8px;font-size: 20px; color: #409eff">| </span>
            <span style="font-size: large;">审核内容</span>
        </el-row>
        <el-form :model="form" :rules="rules" ref="formRef" label-width="100px">
            <el-form-item label="审核状态：" prop="status">
                <el-select v-model="form.status" placeholder="请选择">
                    <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-form>

        <!-- 操作按钮 -->
        <template #footer>
            <el-button type="primary" @click="handleSave">保存</el-button>
            <el-button @click="handleCancel">关闭</el-button>
        </template>
    </el-dialog>
</template>

<script>
import { APPOINTMENT_STATUS } from "@/common/constants.js";

export default {
    name: "InspectDialog",
    emits: ["handleInspect"],
    props: {
        /**
         * 是否显示对话框
         * @type {Boolean}
         */
        visible: {
            type: Boolean,
            required: true,
        },

        /**
         * 表单数据
         * @type {Object}
         */
        form: {
            type: Object,
            required: true,
        },

    },
    data() {
        return {
            /**
             * 审核选项
             * @param {Array}
             */
            options: [{
                value: APPOINTMENT_STATUS["失败"],
                label: "不通过"
                }, {
                value: APPOINTMENT_STATUS["成功"],
                label: "通过"
                }],

            /**
             * 表单验证
             * @param {Object} 
             */
            rules: {
                    status: [
                    { required: true, message: '请审核', trigger: 'change' }
                ],
            },
        }
    },
    methods: {

        /**
         * 关闭操作
         * @returns {void}
         */
        handleCancel() {
            this.$emit("handleInspect", {type: "cancel"});
        },

        /**
         * 保存操作
         * @returns {void}
         */
        handleSave() {
            this.$refs.formRef.validate((valid) => {
                if (valid) {
                    this.$emit("handleInspect", {type: "save", data: {...this.form}})
                }
            })
     
        }
    },
};
</script>

<style lang="scss" scoped></style>